package br.com.appestoque.format;

import java.util.regex.Pattern;

public class CepFormatter implements Formatter {
	
    private final BaseFormatter base;

    static final Pattern FORMATED = Pattern.compile("(\\d{2})[.](\\d{3})[-](\\d{3})");

    static final Pattern UNFORMATED = Pattern.compile("(\\d{2})(\\d{3})(\\d{3})");
    
    public CepFormatter() {
        this.base = new BaseFormatter(FORMATED, "$1.$2-$3", UNFORMATED, "$1$2$3");
    }

    public String format(String value) {
        return base.format(value);
    }

    public String unformat(String value) {
        return base.unformat(value);
    }

}